const url = require("url")
const path = require("path")
module.exports = (req, res, next) => {
    const host = req.headers.host
    let referer = req.headers.referer
    const extname = path.extname(req.path);
    if (![".jpg", ".png", ".webp", ".gif"].includes(extname)) {
        next()
        return;
    }
    if (referer) {
        referer = url.parse(referer).host
    }
    if (referer && host !== referer) {
        req.url = "../public/images/ssy.gif"
    }
    next()
}